<?php require VIEWPATH . ADMIN_DIR . DIRECTORY_SEPARATOR . 'sub' . DIRECTORY_SEPARATOR .'header.php'?>
<style>
    .outer-table {
        margin: 20px 200px;
    }
    .clearfix {
        padding: 30px;
        text-align: center;
    }
    .btn-save {
        width:110px;
        height:40px;
        color: #FFF;
        background:#438EB9;
        border-radius:4px;
        font-size:16px;
        border: none !important;
        margin-right: 100px;
    }
    .copy {
        display: inline-block;
        width:80px;
        height:30px;
        line-height: 30px;
        text-align: center;
        color: #FFF;
        background:#438EB9;
        border-radius:4px;
        margin-left: 20px;
        font-size: 14px;
    }
    .copy:hover {
        color: #FFF;
    }
    .copy:focus {
        color: #FFF;
    }
</style>
<div class="ant-card page-wrap com-card static-page___2-4kT">
    <div class="ant-card-head">
        <div class="ant-card-head-wrapper">
            <div class="ant-card-head-title">官网设置</div>
        </div>
    </div>
    <div class="outer-table">
        <form class="form-horizontal" id="cms-form">
			<input type="hidden" name="cms_logo" value="<?=$setting['cms_logo']?>" />
			<input type="hidden" name="cms_category_banner" value="<?=$setting['cms_category_banner']?>" />
            <input type="hidden"  name="cms_theme_color" value="<?=$setting['cms_theme_color'] ? $setting['cms_theme_color'] : '#8b0012'?>">
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">官网链接</label>
				<div class="col-sm-8">
					<?php if($setting): ?>
                        <input id="cms_link" class="form-control" type="text" value="<?=web_url('cms/index')?>/<?=$setting['cms_token']?>" readonly="" style="width:75%;display:inline;" />
                        <a href="javascript:;" class="copy">复制链接</a>
					<?php else: ?>
						<input class="form-control" type="text" value="请完成官网设置" readonly="" />
					<?php endif; ?>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">官网LOGO</label>
				<div class="col-sm-6" style="margin-top: 10px;">
					<?php if($setting['cms_logo']): ?>
						<a href="javascript:;" id="upload-img">
							<img class="fit-cover" src="<?=$setting['cms_logo']?>" width="160" height="196" />
						</a>
					<?php else: ?>
						<a href="javascript:;" id="upload-img">
							<img class="fit-cover" src="<?=$staticAdminUrl?>sub/assets/img/cms/add.png" width="160" height="196" />
						</a>
					<?php endif; ?>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">
					<a href="javascript:;" data-rel="tooltip" data-original-title="显示的文章分类下的大图">
                        <img src="<?=$staticAdminUrl?>sub/assets/img/cms/question.png" style="height:16px;width:16px;margin-bottom:3px;">
                    </a> 分类大图
				</label>
				<div class="col-sm-6" style="margin-top: 10px;">
					<?php if($setting['cms_category_banner']): ?>
						<a href="javascript:;" id="upload-category-banner">
							<img class="fit-cover" src="<?=$setting['cms_category_banner']?>" width="160" height="196" />
						</a>
					<?php else: ?>
						<a href="javascript:;" id="upload-category-banner">
							<img class="fit-cover" src="<?=$staticAdminUrl?>sub/assets/img/cms/add.png" width="160" height="196" />
						</a>
					<?php endif; ?>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">联系电话</label>
				<div class="col-sm-6">
					<input class="form-control" type="number" name="cms_mobile" placeholder="请填写学校联系电话" value="<?=$setting['cms_mobile']?>" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">学校地址</label>
				<div class="col-sm-6">
					<input class="form-control" type="text" name="cms_address" placeholder="请填写学校通讯地址" value="<?=$setting['cms_address']?>" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">
                    <a href="https://lbs.qq.com/tool/getpoint/" target="_blank" data-rel="tooltip" data-original-title="请填写经纬度地址，点击图标跳转到腾讯地图坐标拾取器">
                        <img src="<?=$staticAdminUrl?>sub/assets/img/cms/question.png" style="height:16px;width:16px;margin-bottom:3px;">
                    </a> 地图定位
				</label>
				<div class="col-sm-6">
					<input class="form-control" type="text" name="cms_position" placeholder="请填写学校所在地址经纬度" value="<?=$setting['cms_position']?>" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">学校简介</label>
				<div class="col-sm-6">
					<textarea class="pd0" id="content" name="cms_content" style="height: 400px;width: 100%"><?=urldecode($setting['cms_content'])?></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">官网主色调</label>
				<div class="col-sm-6" style="margin-top: 10px;">
					<select id="colorpicker" class="hide">
						<option value="#8b0012" selected="">#8b0012</option>
						<option value="#1b467b">#1b467b</option>
						<option value="#0062ad">#0062ad</option>
						<option value="#438EB9">#438EB9</option>
						<option value="#25506b">#25506b</option>
						<option value="#006926">#006926</option>
					</select>
				</div>
			</div>
			<div class="clearfix">
				<div class="">
					<button class="btn-save" type="button">
						提交
					</button>
				</div>
			</div>
		</form>
    </div>
</div>   
<?php require VIEWPATH . ADMIN_DIR . DIRECTORY_SEPARATOR . 'sub' . DIRECTORY_SEPARATOR .'footer.php'?>
<!-- 百度编辑器 -->
<script src="<?=$staticAdminUrl?>assets/ueditor/ueditor.config.js"></script>
<script src="<?=$staticAdminUrl?>assets/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
	$(function(){
		// 上传图片对象
		$("#upload-img").uploader({
			"server":  '<?=UP_FORM_URL?>',
			"authorization": "<?=$signature?>",
			"policy": "<?=$policy?>",
			"callback": function(response) {
				var imgFile = "<?=UP_URL?>" + response.url;
				$("#upload-img").find("img").attr("src", imgFile);
				$("[name=cms_logo]").val(imgFile);
			}
		});
		$("#upload-category-banner").uploader({
			"server":  '<?=UP_FORM_URL?>',
			"authorization": "<?=$signature?>",
			"policy": "<?=$policy?>",
			"callback": function(response) {
				var imgFile = "<?=UP_URL?>" + response.url;
				$("#upload-category-banner").find("img").attr("src", imgFile);
				$("[name=cms_category_banner]").val(imgFile);
			}
		});
		// 赋值
		<?php if($setting && $setting['cms_theme_color']): ?>
			$("#colorpicker").val("<?=$setting['cms_theme_color']?>");
		<?php endif; ?>

		// 颜色选择器
		$('#colorpicker').ace_colorpicker().on("change", function(){
			$("[name=cms_theme_color]").val($(this).val());
		});


		// 初始化编辑器
		var ue = UE.getEditor('content');

		// 提交表单
		var form = $("#cms-form");
		var submitUrl = "<?=admin_url('cms/save_cms_setting')?>";
		form_submit(form, submitUrl, function(res) {
			tips_alert(res.msg, res.success, function(){
				window.location.reload();
			});
        });
        // 点击提交按钮
		$(".btn-save").click(function(){
            // alert(1);
            form.submit();
        })
        // 图标提示
		$(function(){
			$('[data-rel=tooltip]').tooltip();
        });
        // 复制链接
        $(".copy").click(function() {
            var dom = $("#cms_link").select();
            document.execCommand("Copy");
            tips_alert('复制成功', true);
        });
	})
</script>